<% layout('/layouts/default.html', {title: '拟办还文列表', libs: ['dataGrid']}){ %>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa icon-notebook"></i> ${text('拟办还文列表')}
            </div>
            <div class="box-tools pull-right">
                <a href="#" class="btn btn-default" id="btnSearch1"  onclick="batchReturn()" title="${text('批量还文')}"><i class="fa fa-mail-reply"></i>${text('批量还文')}</a>
                <a href="#" class="btn btn-default" id="btnSearch" title="${text('查询')}"><i class="fa fa-filter"></i> ${text('查询')}</a>
            </div>
        </div>
        <div class="box-body">
            <#form:form id="searchForm" model="${docDeliverRecord}" action="${ctx}/sd/docDeliverReturn/listData" method="post" class="form-inline hide"
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
            <div class="form-group">
                <label class="control-label">${text('来文自编号')}：</label>
                <div class="control-inline">
                    <#form:input path="docRecv.docSysCode" maxlength="64" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('领文人警号')}：</label>
                <div class="control-inline">
                    <#form:input path="takeUserPoliceno" maxlength="64" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('文件标题')}：</label>
                <div class="control-inline">
                    <#form:input path="docRecv.docTitle" maxlength="4" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('紧急程度')}：</label>
                <div class="control-inline" style="width: 80px">
                    <#form:select path="docRecv.docEmergLvl"   dictType="recv_doc_emerg_lvl" blankOption="true" class="form-control"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('密级')}：</label>
                <div class="control-inline width-120">
                    <#form:select path="docRecv.secLvl" dictType="recv_sec_lvl" blankOption="true" class="form-control"/>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label">${text('领文单位')}：</label>

                <div class="control-inline width-120">
                    <#form:treeselect id="unit" title="领文单位选择" path="recvUnitCode"
                    url="${ctx}/sd/docDeliverRecord/treeData" class="" allowClear="true" />
                </div>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
                <button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
            </div>
        </#form:form>
        <table id="dataGrid"></table>
        <div id="dataGridPage"></div>
    </div>
</div>
</div>
<% } %>
<script>
function batchReturn(){

    var data=	$('#dataGrid').dataGrid('getSelectRows');
    if (data.length==0){
        js.layer.msg("没有选中文件",{icon:5})
    }else{

    js.layer.open({
        type: 2,
        area: [(js.layer.window.outerWidth - 750) + 'px', (js.layer.window.outerHeight - 500) + 'px'],
        title: '${text("归还文件")}',
        resize: false,
        scrollbar: true,
        maxmin: true,
        content: '${ctx}/sd/docDeliverWaitTake/batchFile',
        success: function (layero, index ) {

        },
        btn: ['<i class="fa fa-check"></i> ${text("归还")}',
            '<i class="fa fa-remove"></i> ${text("取消")}'],
        btn1: function (index, layero) {
            var win = layero.iframeWindow();



                if(win.$("#userCodes").val()==""){
                    if(win.$("#pictureSrc").val()==''){

                        js.layer.msg("请先录入人脸信息",{icon:5})
                        return false;

                    }
                }

                if(win.$("#userName").val()==""){
                    js.layer.msg("清填写还文人姓名", {icon: 5})
                    return false;
                }
                if(win.$("#userPolice").val()==""){
                    js.layer.msg("清填写还文人警号", {icon: 5})
                    return false;
                }


//
            $.ajax({
                type: "POST",
                url: "${ctx}/sd/docDeliverReturn/batchFiles?data="+data+"&userPolice="+win.$("#userPolice").val()+"&userName="+win.$("#userName").val()+"&userCodes="+win.$("#userCodes").val(),
                data:{"face":win.$("#pictureSrc").val()},
                success: function (data) {
                    if(data.result===Global.TRUE){
                        js.layer.msg(data.message, {icon: 5},{time:3000});
                        js.layer.closeAll();
                        page()
                        return true;
                    }
                }
            })
            return false;

        }
    })}

}


    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        showCheckbox: true,
        columnModel: [
            {header:'${text("来文自编号")}', name:'docRecv.docSysCode', index:'c.doc_sys_code', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
                    return '<a href="${ctx}/sd/docDeliverReturn/form?id='+row.id+'" class="btnList" data-title="${text("编辑文件分发")}">'+(val||row.id)+'</a>';
                }},
            {header:'${text("文件文号")}', name:'docRecv.docFullNum', index:'c.doc_full_num', width:150, align:"center"},
            {header:'${text("文件标题")}', name:'docRecv.docTitle', index:'c.doc_title', width:150, align:"center"},
            /*{header:'${text("来文时间")}', name:'docRecv.docRecvDate', index:'c.doc_recv_date', width:150, align:"center"},*/
            {header:'${text("紧急程度")}', name:'docRecv.docEmergLvl', index:'c.doc_emerg_lvl', width:80, align:"center", formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('recv_doc_emerg_lvl')}, val, '${text("未知")}', true);
                }},
            {header:'${text("密级")}', name:'docRecv.secLvl', index:'c.sec_lvl', width:70, align:"center", formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('recv_sec_lvl')}, val, '${text("未知")}', true);
                }},
            {header:'${text("领文单位")}', name:'office.officeName', index:'o.office_name', width:150, align:"center"},
            {header:'${text("领文时间")}', name:'takeDate', index:'take_date', width:150, align:"center"},
            {header:'${text("领文人姓名")}', name:'takeUserName', index:'take_user_name', width:80, align:"center"},

            {header:'${text("领文人警号")}', name:'takeUserPoliceno', index:'take_user_policeno', width:150, align:"center"},

            {header:'${text("操作")}', name:'actions', width:75, sortable:false, title:false, formatter: function(val, obj, row, act){
                    var actions = [];
                <% if(hasPermi('sd:docDeliverReturn:edit')){ %>
                        actions.push('<a href="${ctx}/sd/docDeliverReturn/form?id='+row.id+'" class="btnList" title="${text("查看")}"><i class="fa fa-search"></i></a>&nbsp;&nbsp;&nbsp;');
                        actions.push('<a href="${ctx}/sd/docDeliverRecord/return?id='+row.id+'"  class="btnList" title="${text("还文")}"><i class="fa fa-mail-reply" ></i></a>&nbsp;');
                    <% } %>
                    return actions.join('');
                }}
        ],
        // 加载成功后执行事件
        ajaxSuccess: function(data){

        }
    });
</script>